@import '../../styles/common';

/// Adjusts the spacing for the stack and contained items.
/// @param {String} $spacing - The spacing variant to use.

@mixin stack-spacing($spacing: base) {
  margin-top: -1 * spacing($spacing);
  margin-left: -1 * spacing($spacing);

  > .Item {
    margin-top: spacing($spacing);
    margin-left: spacing($spacing);
    max-width: 100%;
  }
}

.Stack {
  @include stack-spacing;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
}

.noWrap {
  flex-wrap: nowrap;
}

.spacingNone {
  @include stack-spacing(none);
}

.spacingExtraTight {
  @include stack-spacing(extra-tight);
}

.spacingTight {
  @include stack-spacing(tight);
}

.spacingLoose {
  @include stack-spacing(loose);
}

.spacingExtraLoose {
  @include stack-spacing(extra-loose);
}

.distributionLeading {
  justify-content: flex-start;
}

.distributionTrailing {
  justify-content: flex-end;
}

.distributionCenter {
  justify-content: center;
}

.distributionEqualSpacing {
  justify-content: space-between;
}

.distributionFill > .Item {
  flex: 1 1 auto;
}

.distributionFillEvenly > .Item {
  flex: 1 1 auto;

  @supports (min-width: fit-content) {
    flex: 1 0 0%;
    min-width: fit-content;
  }
}

.alignmentLeading {
  align-items: flex-start;
}

.alignmentTrailing {
  align-items: flex-end;
}

.alignmentCenter {
  align-items: center;
}

.alignmentFill {
  align-items: stretch;
}

.alignmentBaseline {
  align-items: baseline;
}

.vertical {
  flex-direction: column;
  margin-left: spacing(none);

  > .Item {
    margin-left: spacing(none);
  }
}

.Item {
  flex: 0 1 auto;
}

.Item-fill {
  flex: 1 1 auto;
}
